home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
tex
/
altrn234.zip
/
ALTERN22.DOC
next >
Wrap
Text File
|
1988-12-02
|
16KB
|
346 lines
ALTERN VERSION 2.2
ALTERNATE AND GLOBAL REPLACEMENT PROGRAM
By C.R.J. Currie
PURPOSE .............................................1
PREPARATION..........................................2
FORMAT OF STRING-LIST FILES..........................3
a) Lists for Alternate Replacement...............3
b) Lists for Global Replacement..................3
FORMAT OF FILE-LIST FILE.............................4
PARAGRAPH MARKER FILES...............................4
RUNNING ALTERN.......................................4
RUNNING THE FILEMAKE PROGRAM.........................5
LIMITATIONS..........................................6
HISTORY..............................................7
SOFTWARE LICENCE.....................................8
Altern v.2.2 documentation (c) C.R.J. Currie 1988 p. 1
ALTERN VERSION 2.2
ALTERNATE AND GLOBAL REPLACEMENT PROGRAM
By C.R.J. Currie
1. PURPOSE
ALTERN is a utility which helps to convert text files to
different formats or to prepare them for input to a
typesetter or output to a printer which your text editor
cannot drive. It allows the global replacement of every
string in a prepared list, or the alternate replacement of
paired strings. The last function is essential to convert
files prepared with a text editor such as Wordstar, which
uses 'toggles' to change text emphasis or type size, to a
format which requires that each style or size be overtly
specified.
Most text editors cannot cope with alternate
replacement, with bulk replacement of a series of strings at
once, or with automatic replacement throughout a set of
files. Some cannot even replace their own control codes.
ALTERN can do all that. It doesn't change your original
file, but makes a modified copy with the extension .COD.
For example a single run could replace every occurrence
of GOAT by ELEPHANT, every carriage return by a linefeed
with the 8th bit set, every odd-numbered occurrence of CAT
by DOG, and every even-numbered occurrence of CAT by SHEEP,
in each one of 100 files.
ALTERN uses single-character input and processes text a
paragraph at at time. The default paragraph marker is the
carriage return -- linefeed sequence (0D0A hex), but files
in formats which use other markers can be read and written.
ALTERN can also search e.g. Wordstar files for strings
in which some bytes may or may not have the eighth bit set,
and replace them. Version 2.2 cannot search independently
of case: REAGAN and Reagan are treated as different strings.
Altern v.2.2 documentation (c) C.R.J. Currie 1988 p. 2
2. PREPARATION
ALTERN requires two prepared files, held in the current
directory, listing codes for replacement: one for those to
be replaced alternately, another for those to be replaced
globally. Even if you only want to do global replacements,
you must prepare a dummy list of alternate replacements (see
3 a) below). If you want to convert more than one file at a
time, you will also need a file listing the files to be
converted. If your input or output files are to have
non-standard paragraph markers you will need a further file
for each of the two possible markers.
These files must be ASCII text files and can be
prepared with a text editor, such as Wordstar in
Non-Document mode, which can write ASCII files, or by
copying the console output to a file. If you need to handle
strings which include characters that cannot be typed from
the keyboard, use the FILEMAKE utility to create the file or
files which list those strings. Your text editor should be
able to load the resulting files so that you can add further
strings to the lists.
Strings which include double quotation marks (") MUST
NOT be included in the lists, but you can type them in while
running ALTERN.
The prepared lists, and the files to be converted, must
be in the current directory unless you have set a data path
with DPATH or some equivalent utility.
The order of sets of strings in the string-list files
is significant. That feature can be used to achieve complex
or tricky replacements: e.g. you can replace 11/21 by some
special code to print it as a fraction, and then replace 1/2
by another special code, in a single run. Doing it the other
way round will give erroneous output.
Altern v.2.2 documentation (c) C.R.J. Currie 1988 p. 3
3. FORMAT OF STRING-LIST FILES
a) LISTS FOR ALTERNATE REPLACEMENT
Each line should include a string to be replaced and the
first and second replacements. Each string should be
inclosed in double quotation marks and separated by a comma
from the next. The last line of the file should consist of
the word END in upper case. Example:
"CAT","DOG","SHEEP"
",",";","."
END
In this example, all occurrences of CAT in the input file or
files will be replaced alternately by DOG and SHEEP in the
output file or files, and all commas will be replaced
alternately by semicolons and full stops.
If you only want a dummy alternate-replacement file, type
only one line of strings, all of which should be the same.
Example:
"A","A","A"
END
b) LISTS FOR GLOBAL REPLACEMENT
Each line should include a string to be replaced and the
string to replace it. Each string should be inclosed in
double quotation marks and the first should be separated by
a comma from the next. The last line of the file should
consist of the word END in upper case. Example:
"GOAT","ELEPHANT"
"*",","
END
In this example, all occurrences of GOAT in the input file
or files will be replaced by ELEPHANT in the output file or
files, and all asterisks will be replaced by commas.
Altern v.2.2 documentation (c) C.R.J. Currie 1988 p. 4
4. FORMAT OF FILE-LIST FILE
The list of files to be converted should consist simply of
one filespec on each line. Example:
CHUMLEY.TXT
DINGBAT
FILE3.DAT
5. PARAGRAPH MARKER FILES
If your input or output files need a paragraph marker other
than the default, you can put them in two files in the
current directory which MUST be called PARIN and PAROUT
respectively. ALTERN always searches the directory for those
files and only uses the defaul